<?php
/*------------------------------------------------------------------------------



------------------------------------------------------------------------------*/

/**
* sort of data-bean class used to carry method call parameters etc
* @author Fred Bird <fredbird@fredbird.org>
* @version 
*/
class wakEvents_Parameters extends dataBean {
/*------------------------------------------------------------------------------
                                                                     constructor
------------------------------------------------------------------------------*/
	/**
	*
	* @access
	* @param
	* @return
	* /
	function wakParameters($properties=array()) {
		$this->__construct($properties);
	}/**/
	
	/**
	* "real" constructor
	*/
	function __construct($properties=array()) {
		$this->structureLock(false);
		parent::__construct($properties);
	}/**/
/*------------------------------------------------------------------------------
                                                                  public methods
------------------------------------------------------------------------------*/
	/**
	* sets data source for member key
	* @param string $member
	* @param string $source data route, see wakDataRouter
	* @access public
	* @return bool
	*/
	function setMemberSource($member,$source) {
		// registering member if needed
		if (!isset($this->$member))
			$this->$member=null;
		// setting member's source setting var
		$key='_'.$member.'_source';
		$this->$key=$source;
		return true;
	}/**/
	/**
	* alias for setmembersource
	*/
	function setSource($member,$source) {
		// registering member if required
		if (!isset($this->$member))
			$this->member=null;
		return $this->setMemberSource($member,$source);
	}
	/**
	* sets a default for member
	* @access public
	* @param string $member
	* @param mixed $default
	* @return bool
	*/
	function setDefault($member,$value) {
		$key='_'.$member.'_default';
		$this->$key=$value;
		// registering member if required
		if (!isset($this->$member))
			$this->member=null;
		return true;
	}/**/
	
	/**
	* specific implementation, retrieving data from source if null
	* @param string $member
	* @access public
	* @return mixed
	*/
	function getMember($member) {
		$sourceKey='_'.$member.'_source';
		$defaultKey='_'.$member.'_default';
		// getting current value
		if (isset($this->$member) and !is_null($this->$member)) {
			$value=$this->$member;
		// getting from defined data source
		} else if(isset($this->$sourceKey)) {
			$router=&wak::getservice('wakdatarouter');
			//echo "<p>getting $member from {$this->$sourceKey}</p>";
			$value=$router->getDataFrom($this->$sourceKey);
		// getting default value if provided
		} else if (isset($this->$defaultKey)) {
			$value=$this->$defaultKey;
		} else {
			$value=null;
		}
		//echo $member.'='.wakapi::vardump($value);
		return $value;
		// output filtering
		//return $this->memberOutputFilter($member,$value);
	}/**/
	function get($member) {
		return $this->getMember($member);
	}
	
	/**
	* sets all member to null
	*/
	function clearAll() {
		$keys=$this->_databean_getmembers();
		foreach ($keys as $key)
			$this->$key=null;
		return true;
	}
/*------------------------------------------------------------------------------
                                                                      properties
------------------------------------------------------------------------------*/
	/**
	* @var type desc
	*/

/*------------------------------------------------------------------------------
                                                                 private methods
------------------------------------------------------------------------------*/
	/**
	* 
	* @param
	* @access private
	* @return 
	* /
	function () {
		
	}/**/
}
?>
